<?php
$this->breadcrumbs=array(
	tt('Settings'),
//	tt('General settings'),
);

$this->h1 = tt('Settings');
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'perfomance-form',
	'enableAjaxValidation'=>false,
)); ?>
	
	
	<?php echo $form->errorSummary($model); ?>

	<?php
	
	$map = $model->getMap();
	$errors = array_keys($model->getErrors());
	$errorTabs = array();
	foreach ($map['settings'] as $category=>$values)
	{
		$errorTabs[$category] = false;
		foreach ($errors as $e)
		{
			$or = (in_array($e, $values)) ? true : false;
			$errorTabs[$category] = $errorTabs[$category]||$or;
		}
	}
	
	$this->widget('application.extensions.MyCJuiTabs', array(
		'tabs' => array(
			tt('General') => array(
				'content' => $this->renderPartial('general', array('model'=>$model, 'form'=>$form, 'type'=>'settings'), true),
				'id' => 'general',
				'error' => $errorTabs['general'],
			),
			tt('SEO settings') => array(
				'content' => $this->renderPartial('seo', array('model'=>$model, 'form'=>$form, 'type'=>'settings'), true),
				'id' => 'seo',
				'error' => $errorTabs['seo'],
			),
			tt('Performance') => array(
				'content' => $this->renderPartial('performance', array('model'=>$model, 'form'=>$form, 'type'=>'settings'), true),
				'id' => 'performance',
				'error' => $errorTabs['cache'],
			),
			tt('Localization') => array(
				'content' => $this->renderPartial('localization', array('model'=>$model, 'form'=>$form, 'type'=>'settings'), true),
				'id' => 'localization',
				'error' => $errorTabs['language'],
			),
		),
		// additional javascript options for the tabs plugin
		'options'=>array(
//			'collapsible'=>true,
		),
		'htmlOptions'=>array('class'=>'shadowtabs'),
	));
	?>
	
	<div class="row buttons">
		<?php echo CHtml::submitButton(tt('Save')); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->